package client;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.MulticastSocket;

public class MulticastClient {
	public static void main(String[] args) throws IOException {

        MulticastSocket socket = new MulticastSocket(6000);
        InetAddress address = InetAddress.getByName("230.0.0.1");
        socket.joinGroup(address);

        DatagramPacket packet;
    
        // get a few quotes
        for (int i = 0; i < 100; i++) {
        	byte[] buf = new byte[256];
            packet = new DatagramPacket(buf, buf.length);
            socket.receive(packet);

            String received = new String(packet.getData(), 0, packet.getLength());
            System.out.println("Date: " + received);
        }

        socket.leaveGroup(address);
        socket.close();
    }
}
